home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / dev / ev_types.h < prev    next >
Text File  |  1995-02-14  |  7KB  |  200 lines

  1. /******************************************************************************
  2.     ev_types.h
  3.     Data types for the events status driver.
  4.     This file contains public API.
  5.     mpaque 11Oct91
  6.     
  7.     Copyright 1991 NeXT Computer, Inc.
  8.     
  9.     Modified:
  10.     
  11. ******************************************************************************/
  12.  
  13. #ifndef _DEV_EV_TYPES_
  14. #define _DEV_EV_TYPES_
  15.  
  16. #import <mach/boolean.h>
  17.  
  18. /* Maximum length of SetMouseScaling arrays */
  19. #define NX_MAXMOUSESCALINGS 20
  20.  
  21. typedef struct evsioKeymapping        /* Match old struct names in kernel */
  22. {
  23.     int size;
  24.     char *mapping;
  25. } NXKeyMapping;
  26.  
  27. typedef struct evsioMouseScaling    /* Match old struct names in kernel */
  28. {
  29.     int numScaleLevels;
  30.     short scaleThresholds[NX_MAXMOUSESCALINGS];
  31.     short scaleFactors[NX_MAXMOUSESCALINGS];
  32. } NXMouseScaling;
  33.  
  34. typedef enum {
  35.     NX_OneButton,
  36.     NX_LeftButton,
  37.     NX_RightButton
  38. } NXMouseButton;
  39.  
  40.  
  41. /*
  42.  * NXEventSystemInfo() information structures.  These are designed to
  43.  * allow for expansion.
  44.  *
  45.  * The current implementation of NXEventSystemInfo() uses an ioctl call.
  46.  * THIS WILL CHANGE.
  47.  */
  48.  
  49. /*
  50.  * Generic query max size and typedefs.
  51.  *
  52.  *    The maximum size is selected to support anticipated future extensions
  53.  *    of request flavors.  Certain flavors planned for future releases may 
  54.  *    require roughtly 800 ints to represent.  We allow a little extra, in
  55.  *    case further growth is needed.
  56.  */
  57. typedef int *NXEventSystemInfoType;
  58. #define NX_EVS_INFO_MAX        (1024)    /* Max array size */
  59. typedef int NXEventSystemInfoData[NX_EVS_INFO_MAX];
  60.  
  61. /* Event System Devices query */
  62. #define NX_EVS_DEVICE_MAX    16
  63.  
  64.     /* Interface types */
  65. #define NX_EVS_DEVICE_INTERFACE_OTHER        0
  66. #define NX_EVS_DEVICE_INTERFACE_NeXT        1 // NeXT custom, in older sys
  67. #define NX_EVS_DEVICE_INTERFACE_ADB        2 // NeXT/fruit keybds/mice
  68. #define NX_EVS_DEVICE_INTERFACE_ACE        3 // For x86 PC keyboards
  69. #define NX_EVS_DEVICE_INTERFACE_SERIAL_ACE    4 // For PC serial mice 
  70. #define NX_EVS_DEVICE_INTERFACE_BUS_ACE        5 // For PC bus mice 
  71. #define NX_EVS_DEVICE_INTERFACE_HIL        6 // For HIL hp keyboard 
  72. #define NX_EVS_DEVICE_INTERFACE_TYPE5        7 // For Sun Type5 keyboard
  73.  
  74. /*
  75.  * Note! if any new interface types are added above, the following
  76.  * definition of the number of interfaces supported must reflect this.
  77.  * This is used in the libkeymap project (storemap.c module) which needs
  78.  * to be cognizant of the number of new devices coming online
  79.  * via support for heterogeneous architecture platforms.
  80.  * e.g., PCs, HP's HIL, Sun's Type5 keyboard,...
  81.  */
  82. #define NUM_SUPPORTED_INTERFACES    (NX_EVS_DEVICE_INTERFACE_TYPE5 + 1)
  83.                     // Other, NeXT, ADB, ACE,...
  84.  
  85.     /* Device types */
  86. #define NX_EVS_DEVICE_TYPE_OTHER    0
  87. #define NX_EVS_DEVICE_TYPE_KEYBOARD    1
  88. #define NX_EVS_DEVICE_TYPE_MOUSE    2    // Relative position devices
  89. #define NX_EVS_DEVICE_TYPE_TABLET    3    // Absolute position devices
  90.  
  91. typedef struct {
  92.     int    interface;    /* NeXT, ADB, other */
  93.     int    interface_addr;    /* Device address on the interface */
  94.     int    dev_type;    /* Keyboard, mouse, tablet, other */
  95.     int    id;        /* manufacturer's device handler ID */
  96. } NXEventSystemDevice;
  97.  
  98. typedef struct {
  99.     NXEventSystemDevice    dev[NX_EVS_DEVICE_MAX];
  100. } NXEventSystemDeviceList;
  101.  
  102. #define __OLD_NX_EVS_DEVICE_INFO        1
  103. #define NX_EVS_DEVICE_INFO            "Evs_EventDeviceInfo"
  104. #define NX_EVS_DEVICE_INFO_COUNT \
  105.     (sizeof (NXEventSystemDeviceList) / sizeof (int))
  106.  
  107. /*
  108.  * Multiprocessor locks used within the shared memory area between the
  109.  * kernel and event system.  These must work in both user and kernel mode.
  110.  * 
  111.  * These routines are public, for the purpose of writing frame buffer device
  112.  * drivers which handle their own cursors.  Certain architectures define a
  113.  * generic display class which handles cursor drawing and is subclassed by
  114.  * driver writers.  These drivers need not be concerned with the following
  115.  * types and definitions.
  116.  *
  117.  * The ev_lock(), ev_unlock(), and ev_try_lock() functions are available only
  118.  * to drivers built in or dynamically loaded into the kernel, and to DPS
  119.  * drivers built in or dynamically loaded into the Window Server.  They do not
  120.  * exist in any shared library.
  121.  */
  122. #ifdef hppa
  123. /*
  124. ** On HPPA, the load&clear command is used for semaphores.  This command
  125. ** requires that the address referenced be 16 byte aligned.  Therefore,
  126. ** make ev_lock_data_t an array of 4 words so that we are sure to have an
  127. ** aligned word to use.
  128. */
  129. typedef volatile struct {
  130.     int lock[4];  /* 4 words so that we have one aligned to 16 bytes! */
  131. } ev_lock_data_t;
  132. typedef ev_lock_data_t    *ev_lock_t;
  133.  
  134. #define ev_init_lock(x)    (*((volatile int *)(((int)(x) + 0x0c) & ~0x0f))  = 1)
  135. #define ev_is_locked(x)    (*((volatile int *)(((int)(x) + 0x0c) & ~0x0f)) == 0)
  136. #else /* hppa */
  137. typedef volatile int    ev_lock_data_t;
  138. typedef ev_lock_data_t    *ev_lock_t;
  139.  
  140. #define ev_init_lock(l)        (*(l) = (ev_lock_data_t)0)
  141. #define ev_is_locked(l)        (*(l) != (ev_lock_data_t)0)
  142. #endif /* hppa */
  143.  
  144. extern void ev_lock(ev_lock_t l);        // Spin lock!
  145. extern void ev_unlock(ev_lock_t l);
  146. extern boolean_t ev_try_lock(ev_lock_t l);
  147.  
  148.  
  149. /* The following typedefs are defined here for compatibility with PostScript */
  150.  
  151. #if !defined(__Point__) && !defined(BINTREE_H)
  152. #define __Point__
  153. typedef struct { short x, y; } Point;
  154. #endif
  155.  
  156. #if !defined(__Bounds__) && !defined(BINTREE_H)
  157. #define __Bounds__
  158. typedef struct { short minx, maxx, miny, maxy; } Bounds;
  159. #endif
  160.  
  161. /*
  162.  * Types used in evScreen protocol compliant operations.
  163.  */
  164.  
  165. typedef enum {EVNOP, EVHIDE, EVSHOW, EVMOVE, EVLEVEL} EvCmd; /* Cursor state */
  166.  
  167. #define EV_SCREEN_MIN_BRIGHTNESS    0
  168. #define EV_SCREEN_MAX_BRIGHTNESS    64
  169. /* Scale should lie between MIN_BRIGHTNESS and MAX_BRIGHTNESS */
  170. #define EV_SCALE_BRIGHTNESS( scale, datum ) \
  171.     ((((unsigned long)(datum))*((unsigned long)scale)) >> 6)
  172.  
  173. /*
  174.  * Definition of a tick, as a time in milliseconds. This controls how
  175.  * often the event system periodic jobs are run.  All actual tick times
  176.  * are derived from the nanosecond timer.  These values are typically used
  177.  * as part of computing mouse velocity for acceleration purposes.
  178.  */
  179. #define EV_TICK_TIME        16            /* 16 milliseconds */
  180. #define EV_TICKS_PER_SEC    (1000/EV_TICK_TIME)    /* ~ 62 Hz */
  181. #define EV_NS_TO_TICK(ns)    ((ns)>>24)
  182. #define EV_TICK_TO_NS(tick)    (((ns_time_t)(tick))<<24)
  183.  
  184. /* Mouse Button bits, as passed from an EventSrc to the Event Driver */
  185. #define EV_RB        (0x01)
  186. #define EV_LB        (0x04)
  187. #define EV_MOUSEBUTTONMASK    (EV_LB | EV_RB)
  188.  
  189. /* Tablet Pressure Constants, as passed from an EventSrc to the Event Driver */
  190. #define EV_MINPRESSURE 0
  191. #define EV_MAXPRESSURE 255
  192.  
  193. /* Cursor size in pixels */
  194. #define EV_CURSOR_WIDTH        16
  195. #define EV_CURSOR_HEIGHT    16
  196.  
  197.  
  198. #endif /* _DEV_EV_TYPES_ */
  199.  
  200.